﻿
<?php
header("Content-Type: text/html; charset=utf-8");
 include("conn.php");

		   mysql_query('SET NAMES UTF8'); 
                 $date=date("Y-m-d h:i:s");
     $rert=mysql_query("select * from message  where (userid ='".$_SESSION[userid]."' and  touserid ='".$_SESSION[user_id]."')or touserid ='".$_SESSION[userid]."' and  userid ='".$_SESSION[user_id]."'order by messageid desc"); 
       while($sdg=mysql_fetch_array($rert))
	   {
	   
	    $rert2=mysql_query("select * from user where userid ='".$sdg[userid]."'"); 
       $user1=mysql_fetch_array($rert2);
	   
	     if($sdg[userid]==$_SESSION[userid])
		    {
		  ?>
			<div class="pydh_divb">
				
				<div class="pydh_divbpic">
					<img src="<?php if($user1[images]!=""){echo $user1[images]; }else{echo "images/weruy.png";}?>" height="60" width="60"/>
				</div>
				<div class="pydh_divbinfo">
					<div class="pydh_divbinfodot">
						<a href="#"><img src="images/xms_r.png" /></a>
					</div>
								
					      <?php echo $sdg[content]; ?>
						  
				</div>
			
			</div>
			<div class="clear"></div>
			<?php } else{?>
			
			
		 
			<div class="pydh_diva">
				<div class="pydh_divapic">
					<img src="<?php if($user1[images]!=""){echo $user1[images]; }else{echo "images/weruy.png";}?>" height="60" width="60"/>
				</div>
				<div class="pydh_divainfo">
					<div class="pydh_divainfodot">
						<a href="#"><img src="images/xms_2.png" /></a>
					</div>
					             	
									<?php echo $sdg[content]; ?>
									
				</div>
			</div>
			<div class="clear"></div>
			<?php }}?>